package com.youhome.business.controller;

import com.github.pagehelper.PageInfo;
import com.youhome.common.exception.CustomException;
import com.youhome.common.response.Result;
import com.youhome.common.response.ResultCode;
import com.youhome.common.response.ResultPage;
import com.youhome.service.model.BCompany;
import com.youhome.service.model.BCounselor;
import com.youhome.service.model.ListHubList;
import com.youhome.service.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by chen365 on 2017/11/17.
 */
@RestController
@RequestMapping(value = "/homepage")
@Api(tags = "公司主页")
public class HomePageController {

    @Autowired
    private BRecommendHouseService bRecommendHouseService;
    @Autowired
    private BCounselorService bCounselorService;
    @Autowired
    private BCompanyService bCompanyService;

    @ApiOperation(value = "公司详情", notes = "获取公司信息详情", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String", name = "uuid", value = "公司UUID", required = true, paramType = "query")
    })
    @GetMapping(value = "/company/details")
    public Object company(String uuid) throws CustomException {
        return new Result(ResultCode.SUCCESS, bCompanyService.selectDetailsByUUID(uuid));
    }

    @ApiOperation(value = "置顶顾问列表", notes = "置顶顾问列表", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String", name = "uuid", value = "公司UUID", required = true, paramType = "query"),
            @ApiImplicitParam(dataType = "int", name = "pageNumber", value = "页码", required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页条数", required = false, paramType = "query")
    })
    @GetMapping(value = "/counselor/istop/list")
    public Object isTopList(String uuid, Integer pageNumber, Integer pageSize) throws CustomException {
        return new ResultPage(ResultCode.SUCCESS, bCounselorService.selectTopByCompanyID(uuid, pageNumber, pageSize));
    }

    @ApiOperation(value = "公司主页--推荐房源列表", notes = "公司主页--推荐房源列表", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String", name = "uuid", value = "公司uuid", required = false, paramType = "path")
    })
    @GetMapping(value = "/recommendhouse/{uuid}")
    public Object recommendHouse(@PathVariable String uuid) throws CustomException {
        return new Result(ResultCode.SUCCESS, bRecommendHouseService.selectRecommendHouseByCompanyId(uuid));
    }

}
